import Vue from "vue";
import VueRouter from "vue-router";
Vue.use(VueRouter);
// import MyHome from "../components/MyHome.vue";
// import MyCom from '../components/MyCom.vue';
// import MyLogin from '../components/MyLogin.vue';
// import MyNews from '../components/MyNews.vue';

const MyHome =()=>import('../components/MyHome.vue');
const MyCom =()=>import('../components/MyCom.vue');
const MyLogin =()=>import('../components/MyLogin.vue');
const MyNews =()=>import('../components/MyNews.vue');
const ComSon =()=>import('../components/ComSon.vue');
const ComSons =()=>import('../components/ComSons.vue');

let router = new VueRouter({
  mode: "history",
  routes: [
    {
      name: "home",
      path: "/",
      component: MyHome,
    },
    {
      name: "home",
      path: "/home/:id",
      component: MyHome,
    },
    {
        name: "MyCom",
        path: "/mycom",
        component: MyCom,
        beforeEnter(to,from,next){
            console.log("beforeEnter ",to,from);
            next()
        },

        children:[{
        name: "comsons",
        path: "comsons",
        component: ComSons,
        },
        {
            name: "comson",
            path: "comson",
            component: ComSon,
            }
    ]
      },
      {
        name: "login",
        path: "/login",
        component: MyLogin,
      },
      {
        name: "news",
        path: "/news",
        component: MyNews,
      },
      
  ],
  linkActiveClass:'mystyle',
  
});
router.beforeEach(function(to,from,next){
    console.log("beforeEach",to,from);
    next()
});
router.afterEach(function(to,from){
    console.log("afterEach",to,from);
});
export default router;